package com.ruoyi.project.bill.controller;


import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.bill.domain.Bill;
import com.ruoyi.project.bill.service.BillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: yp
 * @CreateTime: 2025/7/3
 * @Description: 通用单据接口
 * @Version: 1.0
 */
@RestController
@RequestMapping("/bill")
public class BillController extends BaseController {


    @Autowired
    private BillService billService;

    /**
     * @description:执行单据动作接口
     * @author: yp
     * @date: 2025/7/3 14:10
     * @param: [actionName]动作code，bill提交的数据
     * 实例：
     * {
     *     "billDefine": "test",
     *     "billData": {
     *         "connet": "测试主表",
     *         "is_delete":1,
     *         "test_sub": [
     *             {
     *                 "connet": "测试子表1",
     *                  "is_delete":1
     *             },
     *             {
     *                  "is_delete":1,
     *                 "connet": "测试子表2"
     *             }
     *         ]
     *     }
     * }
     * @return: com.ruoyi.common.core.web.domain.AjaxResult
     **/
    @PostMapping("/exec/{actionCode}")
    public AjaxResult execAction(@PathVariable("actionCode") String actionCode, @RequestBody Bill bill){

        billService.execAction(actionCode,bill);
        return success();
    };


}